package com.example.sword;

import java.util.ArrayList;
import java.util.HashMap;

public class Test37 {

    public static void main(String[] args) {
        System.out.println("haha");

    }


    /**
     * 统计一个数字在升序数组中出现的次数。
     */


    public int GetNumberOfK(int [] array , int k) {
        return helper(array,k)-helper(array,k-1);
    }

    public int helper(int[] array,int k){
        int left = 0;
        int right = array.length-1;
        while (left<=right){
            int mid = (left+right)/2;
            if (array[mid]<=k){
                left = mid+1;
            }else {
                right = mid-1;
            }
        }
        return left;
    }

}
